package com.meta.platform.contract.service.app.impl;

import com.meta.platform.contract.domain.aggr.ContractPlanFundDo;
import com.meta.platform.contract.domain.tunnel.db.ContractPlanFundRepository;
import com.meta.platform.contract.intf.cmd.contractplanfund.AddContractPlanFundCmd;
import com.meta.platform.contract.intf.cmd.contractplanfund.CheckAmountCmd;
import com.meta.platform.contract.intf.cmd.contractplanfund.UpdateContractPlanFundCmd;
import com.meta.platform.contract.service.app.ContractPlanFundAppService;
import com.meta.platform.oplog.common.OperateLogHandler;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 *  合同计划回款
 * @Title:      ContractPlanFundAppServiceImpl
 * @Author:     M.simple
 * @Remark:     The modified content
 * @CreateDate: 2020-12-08 15:53:37
 * @Version:    v2.0
 */
@Service
public class ContractPlanFundAppServiceImpl implements ContractPlanFundAppService{

	@Resource
	private ContractPlanFundRepository crmContractPlanFundRepository;

	@Override
	public ContractPlanFundDo createPlanFund(AddContractPlanFundCmd addContractPlanFundCmd) {
		// 创建基本信息
		ContractPlanFundDo planFundDo = ContractPlanFundDo.create(addContractPlanFundCmd);
		crmContractPlanFundRepository.insertContractPlanFund(planFundDo);
		return planFundDo;
	}

	@Override
	public ContractPlanFundDo updatePlanFund(UpdateContractPlanFundCmd updateContractPlanFundCmd) {
		ContractPlanFundDo fundDo = crmContractPlanFundRepository.getById(updateContractPlanFundCmd.getId());

		if (fundDo == null){
			return null;
		}

		fundDo.update(updateContractPlanFundCmd);
		crmContractPlanFundRepository.updateContractPlanFundByPk(fundDo);

		return fundDo;
	}

	@Override
	public boolean checkPlanAmount(CheckAmountCmd checkAmountCmd){

		return true;
	}

}
